package com.xueke.crawler.dao;

import com.xueke.crawler.model.SubjectTree;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Created by weibo on 2017/5/13.
 *
 * @author weibo.qin
 * @version 2017/5/13
 */
@Mapper
public interface SubjectTreeMapper {


  @Insert("insert into tbl_xueke_tree(nid,pnid,isDeaf,cid,title,domain,uri,dataType,hasCraw,ctime)" +
      "values(#{nid},#{pnid},#{isDeaf},#{cid},#{title},#{domain},#{uri},#{dataType},#{hasCraw},NOW())")
  public void insertSubjectTree(SubjectTree subjectTree);


  @Select("select * from tbl_xueke_tree where cid=13 and  dataType in('2','3') order by dataType desc limit " +
      "#{start}," +
      "#{offset}")
  public List<SubjectTree> querySubjectTree(@Param("start") int start,@Param("offset") int offset);

  @Select("select * from tbl_xueke_tree where dataType in ('sec','chapter') order by dataType desc limit" +
      " " +
      "#{start}," +
      "#{offset}")
  public List<SubjectTree> querySxWlSubjectTree(@Param("start") int start,@Param("offset") int offset);

  @Select("select * from tbl_xueke_tree where cid not in (11,12,13) and dataType in ('node','chapter') order by " +
      "dataType desc limit" +
      " " +
      "#{start}," +
      "#{offset}")
  public List<SubjectTree> queryOtherSubjectTree(@Param("start") int start,@Param("offset") int offset);

}
